import Vue from 'vue'

const componentsContext = require.context('./', true, /\.js$/)
componentsContext.keys().forEach(component => {
  const componentConfig = componentsContext(component)
  // 兼容import export和require module.export两种规范
  const ctrl = componentConfig.default || componentConfig
  console.log(ctrl)
  // 加载全局组件
  if (ctrl && ctrl.name) {
    Vue.component(ctrl.name, ctrl)
  }
})
